<template>
	<view>
		<view class="top bgw p30">
			<view>开卡账户</view>
			<input type="number" v-model="phone" maxlength="11" placeholder="请输入需要开办会员的手机号" value="" />
			<image @tap="phone =''" class="demoves" src="../../static/image/icon_quxiao@2x.png"></image>
		</view>
		<view class="btn p30">
			<button @tap="send" class="btnbg text-lg"> 确认开卡 </button>
		</view>
	</view>
</template>

<script>
	import {
		openVip
	} from '@/api/api.js'
	export default {
		data() {
			return {
				shakeState: 0,
				phone: ''
			};
		},
		methods: {
			async send() {
				if (!/^1[3456789]\d{9}$/.test(this.phone)) {
					uni.showToast({
						title: '手机号不合规',
						icon: 'none'
					})
				} else {
					if (this.shakeState == 0) {
						this.shakeState = 1
						let state = await openVip({
							mobile: this.phone
						})
						if (state.code == 0) {
							this.phone = ''
							this.shakeState = 0
						} else {
							this.shakeState = 0
						}
					}

				}
			}
		}
	}
</script>

<style lang="less" scoped>
	@import './index.less';
</style>
